<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
 
<s:layout-render name="/menu.jsp" nadpis="StudentLectures">
    <s:layout-component name="telo">
    <s:useActionBean beanclass="com.pa165.languageschoolpresentation.StudentActionBean" var="actionBean"/>
    
     <f:message key="Student"/>: <b>${actionBean.studentDTO.name} </b><b>${actionBean.studentDTO.surname} </b><br/>
   <f:message key="Total"/> = ${actionBean.lectures.size()}:
        <table class="table">
            <tr>
                <th><f:message key="Number"/></th>
                <th><f:message key="Id"/></th>
                <th><f:message key="lecture.name"/></th>               
                <th><f:message key="lecture.roomNumber"/></th>
                <th><f:message key="lecture.startTime"/></th>
                <th><f:message key="lecture.endTime"/></th>
                <th><f:message key="Course"/></th>

            </tr>
            <c:forEach items="${actionBean.lectures}" var="lectureDTO" varStatus="loop">
                <tr>
                    <td>${loop.index}</td>
                    <td>${lectureDTO.id}</td>                   
                    <td><c:out value="${lectureDTO.name}"/></td> 
                    <td><c:out value="${lectureDTO.roomNumber}"/></td>
                    <td><c:out value="${actionBean.sdfSource.format(lectureDTO.startTime)}"/></td>
                    <td><c:out value="${actionBean.sdfSource.format(lectureDTO.endTime)}"/></td>
                     <td><c:out value="${lectureDTO.course.name}"/></td>
                </tr>
            </c:forEach>
            
        </table>
        <s:form beanclass="com.pa165.languageschoolpresentation.StudentActionBean">
           <s:hidden name="studentDTO.id"/>
            <fieldset><legend><f:message key="student.enrollToLecture"/></legend>
                <%@include file="enrollStudentToLectureForm.jsp"%>
            <s:submit name="enrollToLecture"><f:message key="student.enroll"/></s:submit>
            </fieldset>
        </s:form>
                <c:if test="${pageContext.request.isUserInRole('ROLE_ADMIN')}" >
        <s:link beanclass="com.pa165.languageschoolpresentation.StudentActionBean" event="all"><f:message key="Back"/></s:link> 
                </c:if>
    </s:layout-component>
</s:layout-render>